package com.atguigu.gmall.order.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.order.service.OrderBizService;
import com.atguigu.gmall.order.vo.OrderSubmitVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description
 * @Return
 * @Author https://weiranyi.github.io
 * @Date Created in 2022-12-21 15:07
 **/
@RequestMapping("api/order/auth")
@RestController
public class OrderApiController {
    @Autowired
    OrderBizService orderBizService;

    // http://api.gmall.com/api/order/auth/submitOrder?tradeNo=GMALL_1671605277053_3 POST
    @PostMapping("/submitOrder")
    public Result submitOrder(@RequestParam("tradeNo") String tradeNo,
                              @RequestBody OrderSubmitVo orderSubmitVo) {
        // 下单方法
        String orderId = orderBizService.submitOrder(tradeNo, orderSubmitVo) + "";
        // 给前端响应 订单id
        return Result.ok(orderId);
    }
}
